1. /* sdfasins.cpp by K.Tsuru */
  2. // function ID 3204 DRADIX
  3. /*****************************************************************
  4. SDouble class
  5. inverse trigonometric function arcsin x by series for |x| < 1.0
  6. If fe <= 0, its value is taken as the value of fixed exponent.
  7. Default argument is declared as fe = INT_MAX > DRADIX_EXP_MAX.
  8. If |x| << |a| and you would like to get an addition
  9. y = a + AsinSeries(x),
  10. it may be better to modify into
  11. y = a + AsinSeries(x, a.RdxExp()).
  12. *****************************************************************/
  13. #ifndef SN_H
  14. #include "sn.h"
  15. #endif
  16. static const char* func = "AsinSeries";
  17. SDouble AsinSeries(const SDouble& x, int fe){
  18. if(x.NetRdxExp() > 0) x.SetError(x.DOMAIN_ERR, func, 3204); // |x| > 1.0
  19. SDouble sum(x), xsq, delta;
  20. ulong n2 = 4, den, num, mt = sum.SlOpMaxValue();
  21. fe = (fe > DRADIX_EXP_MAX) ? x.RdxExp() : fe;
  22. sum.FixedPoint(fe);
  23. xsq = x*x;
  24. delta = DsDiv(x*xsq, 6);
  25. sum += delta;
  26. do{
  27. num = (n2-1)*(n2-1);
  28. den = n2*(n2+1);
  29. if(den >= mt) break;
  30. delta = DsMult(delta, num);
  31. delta = DsDiv(delta*xsq, den);
  32. sum += delta;
  33. n2 += 2;
  34. } while(delta.Sign(3204));
  35. while(delta.Sign(-3204)){
  36. if(n2 + 1 >= mt){
  37. sum.SetError(sum.NOT_CONVERGE, func, -3204);
  38. break;
  39. }
  40. delta = DsMult(delta*xsq, (n2-1));
  41. delta = DsMult(delta, (n2-1));
  42. delta = DsDiv(delta ,n2);
  43. delta = DsDiv(delta ,n2+1);
  44. sum += delta;
  45. n2 += 2;
  46. }
  47. sum.PointFree();
  48. sum.Reform(3204);
  49. sum.upToTerm = n2/2;
  50. return sum;
  51. }

sdfasins.cpp : last modifiled at 2015/12/03 21:34:49(1,526 bytes)
created at 2017/10/07 10:22:50
The creation time of this html file is 2017/10/07 11:29:39 (Sat Oct 07 11:29:39 2017).